﻿

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;

using Gift.DAL;
using Gift.Model;


namespace WebSite.admin.product
{
    public partial class goods_add10 : BaseAdmin
    {

        readonly DALGoodsAttributes theGoodsAttributes = new DALGoodsAttributes();
        tbGoodsAttributes oGoodsAttributes;

        // Methods
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

            if (base.Request.QueryString["gid"] != null)
            {
                oGoodsAttributes = theGoodsAttributes.GetModel(int.Parse(Request.QueryString["gid"]));
                if (oGoodsAttributes == null)
                {
                    oGoodsAttributes = new tbGoodsAttributes();
                    oGoodsAttributes.goodsId = int.Parse(Request.QueryString["gid"]);
                    oGoodsAttributes.saleService = this.txtaContent.InnerText.Replace("'", "''");
                    theGoodsAttributes.Add(oGoodsAttributes);
                }
                else
                {
                    oGoodsAttributes.saleService = this.txtaContent.InnerText.Replace("'", "''");
                    theGoodsAttributes.Update(oGoodsAttributes);
                }

                ExtAspNet.Alert.Show("规格参数修改成功！");
            }
            else
            {
                ExtAspNet.Alert.Show("请先添加商品基本信息！");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!base.IsPostBack)
            {
                this.BindForm();
            }
        }

        private void BindForm()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["gid"]))
            {
                oGoodsAttributes = this.theGoodsAttributes.GetModel(int.Parse(Request.QueryString["gid"]));
                if (oGoodsAttributes != null && oGoodsAttributes.saleService != null)
                {
                    this.txtaContent.InnerText = oGoodsAttributes.saleService.ToString().Replace("''", "'");
                }
  
            }

        }


    }
}